﻿<!DOCTYPE html>
<html lang="en" style="background:#fff;">
<head>
    <base href="${basePath}">
    <#include "common/top.html"/>
    <link type="text/css" rel="stylesheet" href="${basePath}plugins/zTree/3.5.1/zTreeStyle/zTreeStyle.css"/>
    <script type="text/javascript" src="${basePath}plugins/zTree/3.5.1/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="${basePath}plugins/zTree/3.5.1/jquery.ztree.excheck.js"></script>
    <style>
        #testcheckbox {
            width: 1px;
            height: 1px;
        }
       .layui-form-item ul {
            overflow: hidden;
            padding: 0 0 0 2%;
            width: 98%;
        }
        .layui-form-item ul li{
            float: left;
            margin-right: 10%;
            height: 40px;
        }


    </style>
</head>
<body style="background:#fff;">
<form class="layui-form layui-form-pamel" name="form1" id="form1" method="post">
    <div class="layui-form-item-dept">
        <input type="hidden" name="userId" id="userId" value="${userId}"/>
        <input id="roleId" name="roleId" type="hidden" value="${roleId}">
        <div class="layui-form-item">
            <ul>
                <#list sysRole as var >
                    <li>
                           <input type="checkbox" lay-filter="filter" ${var.checked} lay-verify="title" name="roleIds" value="${var.roleId}"
                                  title="${var.roleName}">
                    </li>
                </#list>
            </ul>
        </div>
    </div>
</body>
<script type="text/javascript">

    var roles = '${roles}';
    var form;
    layui.use(['form'], function () {
        form = layui.form();
        form.on('checkbox(filter)',function(data){
            var ids = new Array();
            $('input:checkbox:checked').each(function(){
                ids.push($(this).val());
            });
            $("#roleId").val(ids.join());
        })
    });
    //保 存
    function save() {
        $.ajax({
            url: "${basePath}/sysuser/user/saveUserLimit",
            data: $("#form1").serialize(),
            type: "POST",
            success: function (data) {
                if (data.status == 'success') {
                    parent.layer.alert(data.msg, function (index) {
                        var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index1);
                        parent.layer.close(index);
                    });
                } else {
                    parent.layer.alert(data.msg);
                }
            }
        })
    }
</script>
</html>
